// #include <QGuiApplication>
// #include <QApplication>
// #include <QQmlApplicationEngine>
// #include <QApplicationStatic>
// #include <QChronoTimer>
// #include  <QtQuick>
// #include "dataobject.h"

// int main(int argc, char *argv[])
// {
// #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
//     QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
// #endif

//     QGuiApplication app(argc, argv);

//     const QStringList colorList = {"red",
//                                    "green",
//                                    "blue",
//                                    "yellow"};

//     const QStringList moduleList = {"Core", "GUI", "Multimedia", "Multimedia Widgets", "Network",
//                                     "QML", "Quick", "Quick Controls", "Quick Dialogs",
//                                     "Quick Layouts", "Quick Test", "SQL", "Widgets", "3D",
//                                     "Android Extras", "Bluetooth", "Concurrent", "D-Bus",
//                                     "Gamepad", "Graphical Effects", "Help", "Image Formats",
//                                     "Location", "Mac Extras", "NFC", "OpenGL", "Platform Headers",
//                                     "Positioning", "Print Support", "Purchasing", "Quick Extras",
//                                     "Quick Timeline", "Quick Widgets", "Remote Objects", "Script",
//                                     "SCXML", "Script Tools", "Sensors", "Serial Bus",
//                                     "Serial Port", "Speech", "SVG", "UI Tools", "WebEngine",
//                                     "WebSockets", "WebView", "Windows Extras", "XML",
//                                     "XML Patterns", "Charts", "Network Authorization",
//                                     "Virtual Keyboard", "Quick 3D", "Quick WebGL"};

//     QList<QObject *> dataList;
//     for (const QString &module : moduleList)
//         dataList.append(new DataObject("Qt " + module, colorList.at(rand() % colorList.length())));

//     QQuickView view;
//     view.setResizeMode(QQuickView::SizeRootObjectToView);

//     // view.setInitialProperties({{ "model", QVariant::fromValue(dataList) }});


//     // 或方法2：通过上下文属性（更推荐）
//     view.rootContext()->setContextProperty("myModel", QVariant::fromValue(dataList));

//     view.setSource(QUrl("qrc:/ModelAndVisual2.qml"));
//     view.show();

//     return app.exec();
// }
